package top.kaoshanji.p1ch01a;

import java.io.PrintStream;

/**
 * 代码清单-p1ch01a-8页a：SlayDragonQuest是要注入到 BraveKnight中的Quest实现
 * @author kaoshanji
 * ^_^
 * create time 2025/4/22 9:40
 */
public class SlayDragonQuest implements Quest {

    // 一个依赖项
    private PrintStream stream;

    // 通过构造器注入
    public SlayDragonQuest(PrintStream stream) {
        this.stream = stream;
    }

    @Override
    public void embark() {
        stream.println("Embarking on quest to slay the dragon!");
    }

}
